from flask import Flask
from flask_cors import CORS
import os

# 导入蓝图
from moYanWishers import moYanWishers_bp
from customers import customers_bp

# 初始化Flask应用
app = Flask(__name__)
CORS(app)  # 允许跨域访问

# 注册蓝图
app.register_blueprint(moYanWishers_bp, url_prefix='/api')
app.register_blueprint(customers_bp, url_prefix='/api')

# 健康检查接口
@app.route('/health', methods=['GET'])
def health_check():
    return {"status": "healthy", "service": "modular-api"}, 200

# 初始化数据文件目录
def initialize_directories():
    if not os.path.exists('data'):
        os.makedirs('data')

if __name__ == '__main__':
    initialize_directories()
    app.run(host='0.0.0.0', port=8081, debug=True)
